package com.laowang.project.system.controller;

import java.util.List;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.laowang.framework.aspectj.lang.annotation.Log;
import com.laowang.framework.aspectj.lang.enums.BusinessType;

import org.springframework.web.bind.annotation.*;
import com.laowang.project.system.domain.MyCyhPosition;
import com.laowang.project.system.service.MyCyhPositionService;
import com.laowang.framework.web.controller.BaseController;
import com.laowang.framework.web.domain.AjaxResult;
import com.laowang.common.utils.poi.ExcelUtil;
import com.laowang.framework.web.page.TableDataInfo;

/**
 * 头衔Controller
 *
 * @author laowang
 * @date 2023-08-29
 */
@Api(tags = "头衔接口")
@RestController
@RequestMapping("/position")
public class MyCyhPositionController extends BaseController {
    @Autowired
    private MyCyhPositionService myCyhPositionService;

    @ApiOperation(value = "小程序查询头衔列表 查询头衔列表",notes = "")
    @GetMapping("/web/list")
    public AjaxResult weblist(  ) {
        List<MyCyhPosition> list = myCyhPositionService.selectMyCyhPositionListWeb(null);
        return AjaxResult.success(list);
    }


    /**
     * 查询头衔列表
     */
    @ApiOperation(value = "查询头衔列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:position:list')")
    @GetMapping("/list")
        public TableDataInfo list(MyCyhPosition myCyhPosition) {
        startPage();
        List<MyCyhPosition> list = myCyhPositionService.selectMyCyhPositionList(myCyhPosition);
        return getDataTable(list);
    }

    /**
     * 导出头衔列表
     */
    @ApiOperation(value = "导出头衔列表",notes = "")
    @PreAuthorize("@ss.hasPermi('my:position:export')")
   // @Log(title = "头衔", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(MyCyhPosition myCyhPosition) {
        List<MyCyhPosition> list = myCyhPositionService.selectMyCyhPositionList(myCyhPosition);
        ExcelUtil<MyCyhPosition> util = new ExcelUtil<MyCyhPosition>(MyCyhPosition.class);
        return util.exportExcel(list, "position");
    }

    /**
     * 获取头衔详细信息
     */
    @ApiOperation(value = "获取头衔详细信息",notes = "")
    @PreAuthorize("@ss.hasPermi('my:position:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id) {
        return AjaxResult.success(myCyhPositionService.selectMyCyhPositionById(id));
    }

    /**
     * 新增头衔
     */
    @ApiOperation(value = "新增头衔",notes = "")
    @PreAuthorize("@ss.hasPermi('my:position:add')")
    //@Log(title = "头衔", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MyCyhPosition myCyhPosition) {
        return toAjax(myCyhPositionService.insertMyCyhPosition(myCyhPosition));
    }

    /**
     * 修改头衔
     */
    @ApiOperation(value = "修改头衔",notes = "")
    @PreAuthorize("@ss.hasPermi('my:position:edit')")
    //@Log(title = "头衔", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MyCyhPosition myCyhPosition) {
        return toAjax(myCyhPositionService.updateMyCyhPosition(myCyhPosition));
    }

    /**
     * 删除头衔
     */
    @ApiOperation(value = "删除头衔",notes = "")
    @PreAuthorize("@ss.hasPermi('my:position:remove')")
    //@Log(title = "头衔", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids) {
        return toAjax(myCyhPositionService.deleteMyCyhPositionByIds(ids));
    }
}
